package com.example.cr.generator.enums;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;

public enum HarmLevel {
    LOW("L", "低", 1),
    MEDIUM("M", "中", 2),
    HIGH("H", "高", 3),
    SEVERE("S", "严重", 4);

    private String code;
    private String desc;
    private int level;

    HarmLevel(String code, String desc, int level) {
        this.code = code;
        this.desc = desc;
        this.level = level;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public int getLevel() {
        return level;
    }

    public static List<HashMap<String, String>> getEnumList() {
        List<HashMap<String, String>> list = new ArrayList<>();
        for (HarmLevel anEnum : EnumSet.allOf(HarmLevel.class)) {
            HashMap<String, String> map = new HashMap<>();
            map.put("code", anEnum.code);
            map.put("desc", anEnum.desc);
            list.add(map);
        }
        return list;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    @Override
    public String toString() {
        return "HarmLevel{" +
                "code='" + code + '\'' +
                ", desc='" + desc + '\'' +
                ", level=" + level +
                '}';
    }
}